package com.example.tang.zhayan.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.tang.zhayan.R;
import com.example.tang.zhayan.bean.DbBuyDetail;
import com.squareup.picasso.Picasso;

import org.w3c.dom.Text;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

/**
 * Created by yang on 2015/12/18.
 */

@ContentView(R.layout.activity_order)
public class OrderActivity extends AppCompatActivity implements View.OnClickListener{

    @ViewInject(R.id.iv_back)
    private ImageView iv_back;

    @ViewInject(R.id.iv_order_image)
    private ImageView iv_order_image;

    @ViewInject(R.id.tv_order_name)
    private TextView tv_order_name;

    @ViewInject(R.id.tv_order_size)
    private TextView tv_order_size;

    @ViewInject(R.id.tv_order_price)
    private TextView tv_order_price;

    @ViewInject(R.id.tv_order_color)
    private TextView tv_order_color;

    @ViewInject(R.id.tv_order_num)
    private TextView tv_order_num;

    @ViewInject(R.id.tv_order_office)
    private TextView tv_order_office;

    private DbBuyDetail dbBuyDetail;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        Intent intent = getIntent();
        if(intent.getSerializableExtra("dbInfo") != null){
            dbBuyDetail = (DbBuyDetail) intent.getSerializableExtra("dbInfo");
        }
        initView();
        initData();
    }

    private void initData() {

    }

    private void initView() {
        iv_back.setOnClickListener(this);
        if(dbBuyDetail != null){
            tv_order_color.setText("颜色："+dbBuyDetail.getColor());
            tv_order_name.setText(dbBuyDetail.getName());
            tv_order_num.setText(dbBuyDetail.getCurrentCount());
            tv_order_price.setText(dbBuyDetail.getPrice());
            tv_order_size.setText("尺寸："+dbBuyDetail.getSize());
            tv_order_office.setText("工作室："+dbBuyDetail.getInfo());
            Picasso.with(this).load(dbBuyDetail.getImgUrl()).placeholder(R.mipmap.default_loader_image1).into(iv_order_image);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_back:
                finish();
                break;
        }
    }
}
